// 保存问诊记录数据
import { defineStore } from 'pinia'
import type { PartialConsult, IllnessObj } from '@/types/consult'
import { ref } from 'vue'
import type { ConsultType } from '@/enums'
export const useConsultStore = defineStore('consult', () => {
  // 定义问诊类型
  const consult = ref<PartialConsult>({})
  // 设置问诊类型
  const setType = (type: ConsultType) => {
    consult.value.type = type
  }
  // 设置问诊类型
  const setIllnessType = (type: 0 | 1) => {
    consult.value.illnessType = type
  }
  // 设置科室
  const setDepId = (id: string) => {
    consult.value.depId = id
  }
  // 设置病患信息
  const setIllness = (payload: IllnessObj) => {
    consult.value.illnessDesc = payload.illnessDesc
    consult.value.illnessTime = payload.illnessTime
    consult.value.consultFlag = payload.consultFlag
    consult.value.pictures = payload.pictures
  }
  // 设置患者信息
  const setPatientId = (id: string) => {
    consult.value.patientId = id
  }
  // 设置优惠券
  const setCouponId = (id: string) => {
    consult.value.couponId = id
  }
  // 清除问诊信息
  const clear = () => {
    consult.value = {}
  }
  return {
    consult,
    setType,
    setIllnessType,
    setDepId,
    setIllness,
    setPatientId,
    setCouponId,
    clear
  }
},
{
  persist: true
})